package com.kingscup.gamestates;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.gui.MouseOverArea;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import com.kingscup.KingsCup;

public class MainMenu extends BasicGameState {
        
		Input input;
    

		int stateID = -1;
        //private int stateID;
		
		Image background;
		Image play;
		Image help;
		
		MouseOverArea playy;
		MouseOverArea helpp;
        
        public MainMenu (int stateID) {
                this.stateID = stateID;
        }
        
        
        @Override
    	public void init(GameContainer gameContainer, StateBasedGame sbg)
    			throws SlickException {
        	        	    		
    			background = new Image("assets/menu.jpg");
    			play = new Image("assets/play.png");
    			help = new Image("assets/help.png");
    			
    			playy = new MouseOverArea(gameContainer, play, 240, 500);
    			helpp = new MouseOverArea(gameContainer, help, 500, 500);
    	}
     
    	@Override
    	public void render(GameContainer gameContainer, StateBasedGame sbg, Graphics g)
    			throws SlickException {
    			background.draw(0,0,1024,768);
    			
    			 playy.render(gameContainer, g);
    			 helpp.render(gameContainer, g);
    	}

        @Override
        public void update(GameContainer gc, StateBasedGame sbg, int delt)
                        throws SlickException {
        	
        	input = gc.getInput();
            input.clearMousePressedRecord();
        	
        	if ( playy.isMouseOver() && input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)
                     ){
            					sbg.enterState(KingsCup.PLAYERMENU);
            					
    		  } 
        	
        	if ( helpp.isMouseOver() && input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)
                    ){
           					sbg.enterState(KingsCup.HELPMENU);
           					
   		  } 
                
        }

        @Override
        public int getID() {
                // TODO Auto-generated method stub
                return stateID;
        }

}